(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('apf.l.discount.viewController', viewController);
	viewController.$inject = [ '$scope', '$q', '$filter', 'Constants', 'gridService', 'modalService', 'layoutConfig', 'validatorConfig', 'authService',
			'discountService' ];
	function viewController($scope, $q, $filter, Constants, gridService, modalService, layoutConfig, validatorConfig, authService, discountService) {
		var ctrl = this, 
			params = $scope.$stateParams.params;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.invFinanceRequest ={};
		
		ctrl.init = function() {
			discountService.getDiscountViewOptions().then(function(data){
				ctrl.frReqStatusOptions = data.discountStatus.data;
				authService.view(params).then(function(response) {
					if (response.data) {
						ctrl.invFinanceRequest = response.data;
					}
				});
			});
		};
		
		function assetSelectionChanged(eventRow, selectedRows) {
			ctrl.selectedAsset = selectedRows;
		}
		
		ctrl.viewAsset = function(obj) {
			$scope.go('apf.l.asset.list', {"ivfrRequestId": $filter('encode')(obj.ivfrRequestId)});
		};
		
		ctrl.viewInvoice = function(obj) {
			$scope.go('apf.l.piInquiry.invoice.list', {"ivfrRequestId": $filter('encode')(obj.ivfrRequestId)});
		};
		
	}
})(angular);
